package org.guderin.bookmarkus.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.guderin.bookmarkus.dao.BookmarkDao;
import org.guderin.bookmarkus.model.Bookmark;

public class ListBookmarks extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5887742945363128940L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		BookmarkDao bookmarkDao = new BookmarkDao();
		List<Bookmark> bookmarks = bookmarkDao.list();
		req.setAttribute("bookmarks", bookmarks);
		
		String jsp = "/WEB-INF/pages/listBookmarks.jsp";
		RequestDispatcher rd = getServletContext().getRequestDispatcher(jsp);
		rd.forward(req, resp);	
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		super.doPost(req, resp);
	}



}
